<template>
  <div class="container">
    <van-cell-group>
      <van-field v-model="channelNo" label="channelNo" placeholder="渠道号" />
      <van-field v-model="aac002" label="aac002" placeholder="身份证号" />
      <van-field v-model="aac003" label="aac003" placeholder="姓名" />
      <van-field
        v-model="ggfwPassword"
        label="password"
        placeholder="公共服务密码"
        type="password"
      />
      <van-field
        v-model="signNo"
        label="signNo"
        placeholder="签发号"
        rows="1"
        type="textarea"
      />
      <van-field
        v-model="url"
        label="url"
        placeholder="申领地址"
        rows="5"
        type="textarea"
      />
    </van-cell-group>
    <g-button @click="showSSC">电子社保卡二维码</g-button>
  </div>
</template>

<script>
import Button from "@/components/common/button/Button";
import config from "@/views/test/config";

export default {
  name: "TestShow",
  components: {
    GButton: Button
  },
  data() {
    return {
      channelNo: config.channelNo,
      aac002: config.aac002,
      aac003: config.aac003,
      aab301: config.aab301,
      ggfwPassword: config.ggfwPassword,
      sign: "",
      signNo: ""
    };
  },
  created() {
    document.title = "电子社保卡二维码";
    this.getSSCTestSign();
  },
  computed: {
    url() {
      return `${config.sscServer}/indep/ORCode?channelNo=${this.channelNo}&signNo=${this.signNo}&aac002=${this.aac002}&aac003=${this.aac003}&aab301=${this.aab301}&isIndep=1&isWeb=1&${this.sign}`;
    }
  },
  methods: {
    getSSCTestSign() {
      this.$store
        .dispatch("getSSCTestSign", {
          channelNo: this.channelNo,
          aac002: this.aac002,
          aac003: this.aac003,
          aab301: this.aab301,
          ggfwPassword: this.ggfwPassword
        })
        .then(res => {
          this.sign = res.sign;
          this.signNo = res.signNo;
        });
    },
    showSSC() {
      setTimeout(() => {
        location.href = this.url;
      }, 1000);
    }
  }
};
</script>

<style lang="less" scoped></style>
